/*  Last edited: May  8 16:31 1996 (il) */
#include "fpp.h"

void clonefreemem()
{
  int i;
  int acemax;
  CLONE *clone;
  struct fpdata *p, *ptemp;
  struct remark *r, *rtemp;
  struct markertop *mp,*mptemp;

  if(!acedata)
    return;
  acemax = arrayMax(acedata);
  for(i=0;i<acemax;i++){
    clone = arrp(acedata,i,CLONE);
    p = clone->fp;
    if(p != NULL){
      while(p->next != NULL){
	ptemp = p->next;
	if(!(messfree(p)))
	  printf("error freeing fpdata memory\n");
	p = ptemp;
      }
      if(!(messfree(p)))
	printf("error freeing fpdata memory\n");
    }  
    r = clone->remark;
    if(r != NULL){
      while(r->next != NULL){
	rtemp = r->next;
	if(!(messfree(r)))
	  printf("error freeing remark memory\n");
	r = rtemp;
      }
      if(!(messfree(r)))
	printf("error freeing remark memory\n");
    }  
    r = clone->fp_remark;
    if(r != NULL){
      while(r->next != NULL){
	rtemp = r->next;
	if(!(messfree(r)))
	  printf("error freeing fp remark memory\n");
	r = rtemp;
      }
      if(!(messfree(r)))
	printf("error freeing fp remark memory\n");
    }  
    mp = clone->marker;
    while(mp!=NULL){
      mptemp= mp;
      mp=mp->nextmarker;
      if(!(messfree(mptemp)))
	printf("error freeing marker memory");
    }
  } 
}

int clonefreemarkermem()
{
  int i;
  int acemax,j=0;
  CLONE *clone;
  struct markertop *mp,*mptemp;

  if(!acedata)
    return 0;
  acemax = arrayMax(acedata);
  for(i=0;i<acemax;i++){
    clone = arrp(acedata,i,CLONE);
    mp = clone->marker;
    while(mp!=NULL){
      j++;
      mptemp= mp;
      mp=mp->nextmarker;
      if(!(messfree(mptemp)))
	printf("error freeing marker memory");
    }
    clone->marker = NULL;
  } 
  return j;
}

void ctgfreemem()
{
  if(root!= NULL){
    messfree(root);
    root= NULL;
  }
  clhigh = NULL;
}




